<?php

/**
 * Factory to grab a template loader.
 */
class ResourceLoaderFactory
{
    /**
     * Gets the loader specified in the configuration file.
     * @return ResourceLoader
     */
    public static function getLoader(GeryEngine $engine, $loaderClassName)
    {
        if (class_exists($loaderClassName)) {
        	$loader = new $loaderClassName();
        	
        	
        	$engine->info('Resource Loader instantiated: ' . $loader->getName());
        	
        	return $loader;
        	
        } else {
        	
            $engine->error("Problem instantiating the template loader.\n" .
                          "Could not find the loader class, look at your\n" .
                          "properties file and make sure the name of the\n" .
                          "template loader is correct, and the file is\n" .
                          "included.");
        	
            throw new Exception("Problem initializing resource loader: {$loaderClassName}");
        }
    }
}
?>